home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / fixpf.act < prev    next >
Text File  |  1995-04-22  |  2KB  |  88 lines

  1. Fix for PrintF on Action! Toolkit
  2. ---------------------------------
  3.  
  4. The PrintF routine on the Action!
  5. Toolkit works great unless you try to
  6. print a CARD value greater than
  7. 32767, or try to print the INT value
  8. -32768.  The reason these problems
  9. occur is that the PROC PF_NBase in
  10. the PRINTF.ACT file uses the "/" and
  11. "MOD" operators, which call the
  12. cartridge divide routine.  The divide
  13. routine is a SIGNED divide, so it
  14. doesn't work for large card values.
  15. The solution is to insert an UNSIGED
  16. divide routine into the PRINTF.ACT
  17. file and use it, instead.  First,
  18. insert the following code at the
  19. beginning of PRINTF.ACT:
  20.  
  21.   CARD Quotient, Remainder
  22.  
  23.   PROC UDiv( CARD a, divisor )
  24.       DEFINE GETCARRY="[$2E carry]"
  25.       BYTE carry, i
  26.       CARD temp
  27.  
  28.       Remainder = 0
  29.       FOR i = 1 TO 16
  30.         DO
  31.           Remainder ==LSH 1
  32.           Quotient ==LSH 1
  33.           IF (a&$8000)#0 THEN
  34.               Remainder ==% 1
  35.           FI
  36.           a ==LSH 1
  37.           temp = Remainder - divisor
  38.           GETCARRY
  39.           IF (carry&1)#0 THEN
  40.               Remainder = temp
  41.               Quotient ==+ 1
  42.           FI
  43.         OD
  44.   RETURN
  45.  
  46.  
  47. Some code in the PROCedure PF_NBase
  48. must also be changed.  Find the
  49. section of code that reads as
  50. follows:
  51.  
  52.     WHILE n>0
  53.       DO
  54.       d=n MOD base      <-
  55.       IF d<10 THEN
  56.         d==+'0
  57.       ELSE
  58.         d==+55
  59.       FI
  60.       s(ptr)=d
  61.       ptr==-1
  62.       length==+1
  63.       n=n/base          <-
  64.       OD
  65.  
  66. And change the two lines indicated so
  67. the code reads like this:
  68.  
  69.     WHILE n>0
  70.       DO
  71.       UDiv( n, base )   <-
  72.       d=Remainder       <-
  73.       IF d<10 THEN
  74.         d==+'0
  75.       ELSE
  76.         d==+55
  77.       FI
  78.       s(ptr)=d
  79.       ptr==-1
  80.       length==+1
  81.       n=Quotient        <-
  82.       OD
  83.  
  84.  
  85. The resulting PrintF routine will
  86. work properly for all CARD and
  87. INTeger numbers.
  88. vvvvvvvvvv